//
//  XTCVisitorDetail.m
//  ppkc2016
//
//  Created by 拼凑的断音 on 16/4/13.
//  Copyright © 2016年 拼凑的断音. All rights reserved.
//

#import "XTCVisitorDetail.h"
#import "XXTool.h"

@interface XTCVisitorDetail ()

@property (nonatomic,strong) XVVReleasePersonInfomation *exhibitorShow;

@property (nonatomic,strong) UIImageView *topBackground;

@property (nonatomic,strong) UILabel *exhibitroName;

@end

@implementation XTCVisitorDetail
{
    CGFloat exhibitorShowHeight;
}

-(XVVReleasePersonInfomation*)exhibitorShow
{
    if (_exhibitorShow==nil)
    {
        _exhibitorShow = [[XVVReleasePersonInfomation alloc] init];
        [self addSubview:_exhibitorShow];
    }
    return _exhibitorShow;
}

-(UIImageView*)topBackground
{
    if (_topBackground==nil)
    {
        _topBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"顶部背景图"]];
        _topBackground.contentMode = UIViewContentModeScaleToFill;
        [self addSubview:_topBackground];
    }
    return _topBackground;
}

-(UILabel*)exhibitroName
{
    if (_exhibitroName==nil)
    {
        _exhibitroName = [[UILabel alloc] init];
        _exhibitroName.font = [XXTool systemFontOfSize:17];
        _exhibitroName.textColor = [UIColor whiteColor];
        _exhibitroName.textAlignment = NSTextAlignmentCenter;
        _exhibitroName.numberOfLines = 0;
        [self addSubview:_exhibitroName];
    }
    return _exhibitroName;
}

-(void)refreshLayout:(CGRect)frame
{
    self.topBackground.frame = CGRectMake(0, 0, frame.size.width
                                          , 137);
    self.exhibitroName.frame = _topBackground.frame;
    self.exhibitorShow.frame = CGRectMake(0
                                          , _exhibitroName.frame.origin.y+_exhibitroName.frame.size.height+5
                                          , frame.size.width
                                          , exhibitorShowHeight);
}

-(void)setCellWithData:(XMLVisitorAppointDetailModel *)model personType:(XVVReleasePersonInfomationType)useType
{
    [_exhibitorShow setData:model personType:useType];
    exhibitorShowHeight = [XVVReleasePersonInfomation getHeight:model personType:useType];
    _exhibitroName.text = [NSString stringWithFormat:@"%@\n%@",model.cpnameb_en,model.cpnameb];
    [self refreshLayout:self.frame];
}

+(CGFloat)getHeight:(XMLVisitorAppointDetailModel *)model personType:(XVVReleasePersonInfomationType)useType
{
    return [XVVReleasePersonInfomation getHeight:model personType:useType]+137+10;
}

@end
